#!/usr/bin/env python
#-------------------------------------------------------------------------------
#   file global_ids.py
#   brief
#       ZetCode wxPython tutorial
#
#       author: Jan Bodnar
#       website: www.zetcode.com
#       last modified: September 2011
#
#   $Id: $
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
import wx

ID_MENU_NEW = wx.NewId()
ID_MENU_OPEN = wx.NewId()
ID_MENU_SAVE = wx.NewId()

msg_items = {
    ID_MENU_NEW  : 'New',
    ID_MENU_OPEN : 'Open',
    ID_MENU_SAVE : 'Save'
}

class Example(wx.Frame):
           
    def __init__(self, *args, **kw):
        super(Example, self).__init__(*args, **kw) 
        self.InitUI()
                
    def InitUI(self):
        self.CreateMenuBar()
        self.CreateStatusBar()
        self.SetSize((250, 180))
        self.SetTitle('Global IDs')
        self.Centre()
        self.Show(True)  
        
    def CreateMenuBar(self):
        mb = wx.MenuBar()
        fMenu = wx.Menu()
        fMenu.Append(ID_MENU_NEW, 'New')
        fMenu.Append(ID_MENU_OPEN, 'Open')
        fMenu.Append(ID_MENU_SAVE, 'Save')
        mb.Append(fMenu, '&File')
        self.SetMenuBar(mb)
        self.Bind(wx.EVT_MENU, self.DisplayMessage, id=ID_MENU_NEW)
        self.Bind(wx.EVT_MENU, self.DisplayMessage, id=ID_MENU_OPEN)
        self.Bind(wx.EVT_MENU, self.DisplayMessage, id=ID_MENU_SAVE)        
        
    def DisplayMessage(self, e):
        sb = self.GetStatusBar()
        msg = "%s menu item selected" % msg_items[e.GetId()]
        sb.SetStatusText(msg)

#-------------------------------------------------------------------------------
#   Main entry point
#   - Init the application
#   - Run the main loop
#-------------------------------------------------------------------------------
def main():
    ex = wx.App()
    Example(None)
    ex.MainLoop()    


#-------------------------------------------------------------------------------
#   Run main (if main)
#-------------------------------------------------------------------------------
if __name__ == '__main__':
    main()

#
#   End: global_ids.py
#
